package cn.pegasus.teamwork.pegasus.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.pegasus.teamwork.pegasus.entity.BussServiceProject;
import cn.pegasus.teamwork.pegasus.entity.BussUcenterArea;
import cn.pegasus.teamwork.pegasus.entity.BussUserComment;
import cn.pegasus.teamwork.pegasus.mapper.BussUserCommentMapper;
import cn.pegasus.teamwork.pegasus.service.BussUserCommentService;
import cn.iyizhan.teamwork.base.service.impl.BaseServiceImpl;
import cn.iyizhan.teamwork.base.util.PageHelper;
import cn.iyizhan.teamwork.base.util.PageObject;

/**
 * @author ryan.bian
 * @version 
 */
@Service("bussUserCommentService")
public class BussUserCommentServiceImpl extends BaseServiceImpl<BussUserComment, BussUserCommentMapper> implements BussUserCommentService {
	// 注入当前dao对象
    @Autowired
    private BussUserCommentMapper bussUserCommentMapper;

    public BussUserCommentServiceImpl() {
        setMapperClass(BussUserCommentMapper.class, BussUserComment.class);
    }

	@Override
	public PageObject<BussUserComment> PageList(Map<String, Object> map) {
		int totalData = bussUserCommentMapper.getCount(map);
        PageHelper pageHelper = new PageHelper(totalData, map);
        List<BussUserComment> list = bussUserCommentMapper.findListByPage(pageHelper.getMap());
        PageObject<BussUserComment> pageObject = pageHelper.getPageObject();
        pageObject.setDataList(list);
		return pageObject;
	}

	@Override
	public void addComment(Long userId, String id, String descs) {
		String[] ids = id.split(",");
		for(String s : ids){
			BussUserComment c = new BussUserComment();
			c.setFid(Integer.valueOf(s));
			c.setType(2);
			c.setUserId(userId);
			c.setDescs(descs);
			c.setCreateTime(new Date());
			c.setLastUpdateTime(new Date());
			bussUserCommentMapper.addComment(c);
		}
		
	}

	@Override
	public List<BussUserComment> findComment(Long id) {
		return bussUserCommentMapper.findComment(id);
	}
    
 
}
